package edu.lingnan.blog.user.service.impl;


import edu.lingnan.blog.user.service.MenuService;
import edu.lingnan.blog.user.service.PermissionService;
import edu.lingnan.blog.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * @author cql
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private RoleService roleService;

    @Autowired
    private MenuService menuService;

    @Override
    public Set<String> getRolePermission(Integer userId) {
        Set<String> roles = new HashSet<String>();
        roles.addAll(roleService.selectRolePermissionByUserId(userId));
        return roles;
    }

    @Override
    public Set<String> getMenuPermission(Integer userId) {
        Set<String> perms = new HashSet<String>();
        perms.addAll(menuService.selectMenuPermsByUserId(userId));
        return perms;
    }
}
